﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace E5_KhuyenMaiVang.Models
{    
    public class CompanyManager
    {
        private static GoldDealEntities dbGoldDeal = new GoldDealEntities();

        public static void AddCompany(CompanyView company, Guid ID)
        {
            COMPANY tbcompany = new COMPANY();
            tbcompany.CompanyID = company.CompanyID;
            tbcompany.CompanyName = company.CompanyName;
            tbcompany.TaxCode = company.Taxcode;
            tbcompany.Address = company.Address;
            tbcompany.Email = company.Email;
            tbcompany.Website = company.Website;
            tbcompany.Description = company.Decription;
            tbcompany.Phone = company.Phone;
            tbcompany.Account = ID;

            dbGoldDeal.AddToCOMPANY(tbcompany);
            dbGoldDeal.SaveChanges();
        }
        public static CompanyView ToCompanyView(COMPANY company)
        {
            CompanyView cv = new CompanyView();
            cv.CompanyName = company.CompanyName;
            cv.Taxcode = company.TaxCode;
            cv.Address = company.Address;
            cv.Website = company.Website;
            cv.Phone = company.Phone;
            cv.Decription = company.Description;
            return cv;
        }        

        public static void ToCompany(COMPANY c, CompanyView company)
        {
            c.CompanyName = company.CompanyName;
            c.Address = company.Address;           
            c.Phone = company.Phone;
            c.TaxCode = company.Taxcode;
            c.Website = company.Website;
            c.Description = company.Decription;            
        }
    }
}